package com.tallysystem.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.tallysystem.dao.UserDao;
import com.tallysystem.daoimpl.UserDaoImpl;
import com.tallysystem.entity.User;

@WebServlet("/userview")
public class UserViewServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		String name = (String)session.getAttribute("username");
//		System.out.println(name);

		UserDao userDao = new UserDaoImpl();
		User usertext = userDao.findByname(name);
		ArrayList<User> userlist = new ArrayList<User>();
		userlist.add(usertext);
		request.setAttribute("userlist", userlist);
		
		request.getRequestDispatcher("getpersonal.jsp").forward(request, response);
		
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
